App({
  globalData: {
    gameState: {
      completedLevels: [],
      persuasionValues: {
        guard: 50,
        minister: 30,
        king: 20,
      },
    },
    levels: {
      guard: {
        id: "guard",
        name: "城门试炼",
        title: "守卫关卡",
        image: "/images/guard.png",
        initialPersuasion: 50,
        maxPersuasion: 100,
        dangerThreshold: 20,
        normalColor: "#4CAF50",
        dangerColor: "#F44336",
        borderColor: "#FFFFFF",
      },
      minister: {
        id: "minister",
        name: "宫廷试炼",
        title: "宰相关卡",
        image: "/images/minister.png",
        initialPersuasion: 30,
        maxPersuasion: 100,
        dangerThreshold: 10,
        normalColor: "#FFC107",
        dangerColor: "#D32F2F",
        borderColor: "#FFFF00",
      },
      king: {
        id: "king",
        name: "王座试炼",
        title: "国王关卡",
        image: "/images/king.png",
        initialPersuasion: 20,
        maxPersuasion: 100,
        dangerThreshold: 0,
        normalColor: "#E91E63",
        dangerColor: "#B71C1C",
        borderColor: "#FF0000",
      },
    },
  },

  onLaunch() {
    // 加载游戏存档
    const savedData = wx.getStorageSync("gameState")
    if (savedData) {
      this.globalData.gameState = { ...this.globalData.gameState, ...savedData }
    }
  },

  saveGameState() {
    wx.setStorageSync("gameState", this.globalData.gameState)
  },
})
